--[[=========================================================
	GAMEMODE FUNCTIONS
=========================================================]]--

--[[-----------------------------------------------------]]--
--	Checks whether this gamemode is the base or not
--[[-----------------------------------------------------]]--
function GM:IsBase()
	return self.BaseClass.ThisClass == "gamemode_base"
end

--[[=========================================================
	GLOBAL FUNCTIONS
=========================================================]]--

--[[-----------------------------------------------------]]--
--	Check if an object is an instance of a class
--[[-----------------------------------------------------]]--
function IsValidInstance( obj, class )
	return ( IsTable( obj ) or IsPanel( obj ) ) and obj.is_a and obj:is_a( class )
end

--[[-----------------------------------------------------]]--
--	Check if an SQL result led to an error
--[[-----------------------------------------------------]]--
function IsSQLError( result )
	return not result and sql.LastError()
end

--[[-----------------------------------------------------]]--
--	Check if an SQL result is empty
--[[-----------------------------------------------------]]--
function IsSQLEmpty( result )
	return not result or  not result[1]
end

--[[=========================================================
	PRIMITIVE TYPE CHECKS
=========================================================]]--

/* Number */
function IsNumber( value )
	return value and type( value ) == "number"
end

/* Integer */
function IsInt( value )
	return IsNumber( value ) and value % 1 == 0
end

/* Float */
function IsFloat( value )
	return IsNumber( value ) and value % 1 != 0
end

/* String */
function IsString( value )
	return value and type( value ) == "string"
end

/* Table */
function IsTable( value )
	return value and type( value ) == "table"
end

/* GUI Panel */
function IsPanel( value )
	return value and value != NULL and type( value ) == "Panel"
end

/* Function */
function IsFunction( value )
	return value and type( value ) == "function"
end

/* Boolean */
function IsBool( value )
	return type( value ) == "boolean"
end

/* Angle */
function IsAngle( value )
	return value and type( value ) == "Angle"
end

/* Color */
function IsColor( value )
	return
		IsTable( value ) and
		IsInt( value.r ) and
		IsInt( value.g ) and
		IsInt( value.b ) and
		IsInt( value.a )
end